#delimit;
u $data\edex_data_analytic, clear;
keep cbyrace* gend cbyerace* cbymrace* egend mgend  bytm26c byte26c cbyte29 cbytm29 emajor mmajor cbytehdeg cbytmhdeg;
save $data\teacherchar, replace;
u $data\teacherchar, clear;
rename cbymrace* cbytrace*;
rename mgend tgend;
rename bytm26c byt26c;
rename cbytm29 byt29;
rename mmajor tmajor;
rename cbytmhdeg cbythdeg ;
gen math = 1;
save $data\math, replace;
u $data\teacherchar, clear;
rename cbyerace* cbytrace*;
rename egend tgend;
rename byte26c byt26c;
rename cbyte29 byt29;
rename emajor tmajor;
rename cbytehdeg cbythdeg ;
gen math = 0;
append using $data\math;
save $data\engmath, replace;

gen nonwhite = 1-cbytrace6; label var nonwhite "Non-White";
label var math "Math Teacher"; label var tgend "Male"; label var byt26c "Years of Experience";
gen lessexp = byt26c<=3; label var lessexp " $ \leq $ Three years of Experience";
label var byt29 "No teaching certificate";
label var tmajor "Major in subject taught";
label var cbythdeg "Has graduate degree";
label var cbyrace1 "American Indian";
label var cbyrace2 "Asian";
label var cbyrace3 "Black";
label var cbyrace4 "Hispanic";
label var cbyrace5 "Multiple Race";
label var gend "Male";

/* this creates table S4 */ ;
eststo clear;
qui eststo: estpost sum nonwhite math tgend byt26c lessexp byt29 tmajor cbythdeg cbyrace1 cbyrace2 cbyrace3 cbyrace4 cbyrace5 gend;
qui eststo: estpost sum nonwhite math tgend byt26c lessexp byt29 tmajor cbythdeg cbyrace1 cbyrace2 cbyrace3 cbyrace4 cbyrace5 gend if math==1;
qui eststo: estpost sum nonwhite math tgend byt26c lessexp byt29 tmajor cbythdeg cbyrace1 cbyrace2 cbyrace3 cbyrace4 cbyrace5 gend if math==0;
qui eststo: estpost sum nonwhite math tgend byt26c lessexp byt29 tmajor cbythdeg cbyrace1 cbyrace2 cbyrace3 cbyrace4 cbyrace5 gend if cbytrace6==1;
qui eststo: estpost sum nonwhite math tgend byt26c lessexp byt29 tmajor cbythdeg cbyrace1 cbyrace2 cbyrace3 cbyrace4 cbyrace5 gend if cbytrace3==1;
qui eststo: estpost sum nonwhite math tgend byt26c lessexp byt29 tmajor cbythdeg cbyrace1 cbyrace2 cbyrace3 cbyrace4 cbyrace5 gend if tgend==1;
qui eststo: estpost sum nonwhite math tgend byt26c lessexp byt29 tmajor cbythdeg cbyrace1 cbyrace2 cbyrace3 cbyrace4 cbyrace5 gend if tgend==0;
esttab using $tables\table_s4.tex, replace label  cells(mean(fmt(2)) sd(fmt(2) par));

gen race = .; replace race=1 if cbytrace6==1; replace race=0 if cbytrace3==1;

mat testres = 0;
foreach var of varlist nonwhite math tgend byt26c lessexp byt29 tmajor cbythdeg cbyrace1 cbyrace2 cbyrace3 cbyrace4 cbyrace5 gend {;
qui ttest `var', by(race);
qui mat t = r(p);
qui mat testres = testres, t;
};
esttab mat(testres) using $tables\table_s4.tex, append;

